package _99Exercise;

public class Student implements Comparable<Student> {
	// 让用户输入10个学生的学号 姓名 语文成绩 数学成绩 英语成绩 放入相应的集合容器
	int studentId;
	String name;
	int chineseScore;
	int mathScore;
	int englishScore;

	@Override
	public String toString() {
		return "Student [studentId=" + studentId + ", name=" + name + ", chineseScore=" + chineseScore + ", mathScore="
				+ mathScore + ", englishScore=" + englishScore + ", totalScore="
				+ (chineseScore + mathScore + englishScore) + "]";
	}

	public Student() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Student(int studentId, String name, int chineseScore, int mathScore, int englishScore) {
		super();
		this.studentId = studentId;
		this.name = name;
		this.chineseScore = chineseScore;
		this.mathScore = mathScore;
		this.englishScore = englishScore;
	}

	@Override
	public int compareTo(Student o) {
		// TODO Auto-generated method stub

		// * 按照语文成绩从第到高排序
//		if (this.chineseScore < o.chineseScore) {
//			return -1;
//		} else if (this.chineseScore == o.chineseScore) {
//			return 0;
//		} else {
//			return 1;
//}
		// * 先按照总分从高到底排序
		// * 如果总分一致，按照语文成绩从高到底排序
		// * 如果语文一致，按照数学程序从高到底排序
		// * 如果数学也一致，按照学号从低到高排序
		int totalScore1 = this.chineseScore + this.mathScore + this.englishScore;
		int totalScore2 = o.chineseScore + o.mathScore + o.englishScore;
		if (totalScore1 < totalScore2)
			return 1;
		else if (totalScore1 > totalScore2)
			return -1;
		else if (this.chineseScore < o.chineseScore)
			return 1;
		else if (this.chineseScore > o.chineseScore)
			return -1;
		else if (this.mathScore < o.mathScore)
			return 1;
		else if (this.mathScore > o.mathScore)
			return -1;
		else if (this.studentId < o.studentId)
			return -1;
		else if (this.studentId > o.studentId)
			return 1;
		else
			return 0;
	}

}
